//类的继承

interface ClockInterface{
    tick()
}
interface ClockConstructor{
    new(hour:number,minute:number):ClockInterface
}

function createClocks(ctor:ClockConstructor,hour:number,minute:number):ClockInterface{
    return new ctor(hour,minute)
}

class DigitalClock implements ClockInterface{
    constructor(h:number,m:number){

    }
    tick(){
           console.log('beep beep') 
    }
}

class AnalogClock implements ClockInterface{
    constructor(h:number,m:number){

    }
    tick(){
           console.log('tik tik') 
    }
}

let digital=createClocks(DigitalClock,12,17);
let analog=createClocks(AnalogClock,13,23)


//继承接口 混合类型
interface Counter{
    (start:number):string,

    interval:number

    reset():void
}

function getCounter():Counter{
    let counter=(function(star:number){}) as Counter
    counter.interval=123
    counter.reset=function(){}
    return counter
}
let c=getCounter()
c(10)
c.reset()
c.interval=5.0
// 接口继承类
class Control {
    private state:any
}
interface SelectableControl extends Control {
    select()
}
class Button extends Control implements SelectableControl{
    select(){
    }
}

class TextBox extends Control {
    select(){
    }
}
